﻿using System.Windows.Input;
using AvalonDock.Properties;

namespace AvalonDock
{
    /// <summary>
    /// Defines commands that can be executed against a DockableContent
    /// </summary>
    public sealed class DockableContentCommands
    {
        #region Constants and Fields

        private static readonly object syncRoot = new object();

        private static RoutedUICommand autoHideCommand;

        private static RoutedUICommand dockableWindowCommand;

        private static RoutedUICommand documentCommand;

        private static RoutedUICommand floatingWindowCommand;

        #endregion

        #region Public Properties

        /// <summary>
        /// Shows the <see cref="DockableContent"/> as a <see cref="DockableFloatingWindow"/> which overlays the <see cref="DockingManager"/>
        /// </summary>
        /// <remarks>A floating window can't be redocked to the docking manager.</remarks>
        public static RoutedUICommand DockableFloatingWindow
        {
            get
            {
                lock (syncRoot)
                {
                    if (null == dockableWindowCommand)
                    {
                        dockableWindowCommand =
                            new RoutedUICommand(
                                Resources.DockableContentCommands_DockableFloatingWindow,
                                "DockableFloatingWindow",
                                typeof(DockableContentCommands));
                    }
                }
                return dockableWindowCommand;
            }
        }

        /// <summary>
        /// Shows the <see cref="DockableContent"/> as a <see cref="FloatingWindow"/> which overlays the <see cref="DockingManager"/>
        /// </summary>
        /// <remarks>A floating window can't be redocked to the docking manager.</remarks>
        public static RoutedUICommand FloatingWindow
        {
            get
            {
                lock (syncRoot)
                {
                    if (null == floatingWindowCommand)
                    {
                        floatingWindowCommand = new RoutedUICommand(
                            Resources.DockableContentCommands_FloatingWindow,
                            "FloatingWindow",
                            typeof(DockableContentCommands));
                    }
                }
                return floatingWindowCommand;
            }
        }

        /// <summary>
        /// Shows the DockableContent as a tabbed document
        /// </summary>
        public static RoutedUICommand ShowAsDocument
        {
            get
            {
                lock (syncRoot)
                {
                    if (null == documentCommand)
                    {
                        documentCommand = new RoutedUICommand(
                            Resources.DockableContentCommands_ShowAsDocument,
                            "Document",
                            typeof(DockableContentCommands));
                    }
                }
                return documentCommand;
            }
        }

        /// <summary>
        /// Gets the toggle auto hide.
        /// </summary>
        public static RoutedUICommand ToggleAutoHide
        {
            get
            {
                lock (syncRoot)
                {
                    if (null == autoHideCommand)
                    {
                        autoHideCommand = new RoutedUICommand(
                            Resources.DockableContentCommands_ToggleAutoHide,
                            "AutoHide",
                            typeof(DockableContentCommands));
                    }
                }
                return autoHideCommand;
            }
        }

        #endregion
    }
}